import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_douban/config/app_colors.dart';
import 'package:flutter_douban/main_page/home/h5_detail_page/activity_detail_page.dart';
import 'package:flutter_douban/model/active_model.dart';

class ActivityView extends StatelessWidget {
  final ActiveModel model;
  const ActivityView({Key? key,required this.model}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 12,right: 12,top: 20),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          InkWell(
            onTap: (){
              Navigator.of(context).push(MaterialPageRoute(builder: (_) {
                return ActivityDetail(
                  url: model.url,
                  titleStr: model.name,
                );
              }));
            },
            child: ClipRRect(
              child: CachedNetworkImage(
                imageUrl: model.image!,
                fit: BoxFit.cover,
                width: MediaQuery.of(context).size.width,
                height: (MediaQuery.of(context).size.width-24)/7*4,
              ),
              borderRadius: BorderRadius.circular(4),
            ),
          ),
          SizedBox(height: 10,),
          Row(
            children: [
              Container(
                width: MediaQuery.of(context).size.width-24-90,
                child: Text(
                  model.name!,
                  style: TextStyle(
                    fontSize: 14,
                    fontWeight: FontWeight.bold,
                    color: Colors.black,
                  ),
                ),
              ),
              InkWell(
                child: Container(
                  alignment: Alignment.bottomRight,
                  width: 90,
                  child: Text(
                    '立即参与 >',
                    style: TextStyle(
                      fontSize: 14,
                      fontWeight: FontWeight.bold,
                      color: Color.fromRGBO(119, 163, 155, 1),
                    ),
                  ),
                ),
              )
            ],
          ),
        ],
      ),
    );
  }

}
